Technical Q&A OPS20
Fixed Math Rounding


Q: When I call FixMul (3, 1 << 15) (3*0.5), the result is 2, but FixMul (-3, 1 << 15) yields a result of -1. Furthermore, on 68K Macs FixMul (-3, 1 << 15) yields a result of -2. What's going on?

A: This has to do with the rounding needed to make QuickDraw work correctly on PowerPC-based Macintoshes. The Fixed math routines round up, which in the case of negative numbers is towards zero, so -1.5 rounds to -1, and 1.5 rounds to 2.

This behavior is not going to change, and if this causes problems, you will either need to write your own Fixed math routines or wrap the Apple ones to account for the different rounding direction.

Updated: 17-May-1999


Developer Documentation | Technical Notes | Development Kits | Sample Code